import os
from datetime import datetime


base_dir = os.path.abspath(os.path.dirname(__file__))

# 用户名 和密码
user = input("用户名：")
password = input("密码：")
line = "{}|{}\n".format(user, password)

# 判断文件夹是否存在，不存在则创建
date_string = datetime.now().strftime("%Y-%m")
folder_path = os.path.join(base_dir, 'db2', date_string)
if not os.path.exists(folder_path):
    os.makedirs(folder_path)

# 拼接文件路径
file_path = os.path.join(folder_path, 'account.txt')
with open(file_path, mode='a', encoding='utf-8') as f:
    f.write(line)
